package com.flyee.utils
{
	import mx.logging.Log;
	import mx.logging.LogEventLevel;
	import mx.logging.targets.TraceTarget;
	
	public class MyLog
	{
		public static var isDebug:Boolean = false;
		private static var LOG_TARGET:String = "ManagerCenter";
		private static var instance:MyLog = null;
		
		public function MyLog()
		{
			if(instance){
				throw new Error("log singleton is error!!!");
			}
			init();
		}
		
		public static function getInstance():MyLog{
			if(!instance){
				instance = new MyLog();
			}
			return instance;
		}
		
		public static function info(mess:Object):void{
			if(isDebug){
				Log.getLogger(LOG_TARGET).info(mess.toString());
			}
		}
		
		public static function debug(mess:Object):void{
			if(isDebug){
				Log.getLogger(LOG_TARGET).debug(mess.toString());
			}
		}
		
		public static function warn(mess:Object):void{
			if(isDebug){
				Log.getLogger(LOG_TARGET).warn(mess.toString());
			}
		}
		
		public static function error(mess:Object):void{
			if(isDebug){
				Log.getLogger(LOG_TARGET).error(mess.toString());
			}
		}
		
		private function init():void{
			var logTarget:TraceTarget = new TraceTarget();
			logTarget.level = LogEventLevel.ALL;
				//logTarget.filters = ["*"];
			logTarget.includeDate = true;
			logTarget.includeLevel = true;
			logTarget.includeTime = true;
			logTarget.includeCategory = false;
			Log.addTarget(logTarget);
		}
		
		public function clear():void
		{
			instance = null;
		}

	}
}